package com.mes.cloud.produce.controller;

import com.enbatis.mybatisplugs.base.BaseController;
import com.enbatis.mybatisplugs.commons.utils.ResultReturn;
import com.mes.cloud.feign.base.SysUserFeign;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("v1/test")
public class TestController extends BaseController {
    @Autowired
    private SysUserFeign sysUserFeign;

    @HystrixCommand(fallbackMethod = "hystrixFail")
    @GetMapping("/temp")
    public ResultReturn get() {
        return success(sysUserFeign.getUser(1L));
    }


//    @HystrixCommand(fallbackMethod = "hystrixFail")
//    @GetMapping("/temp")
//    public ResultReturn get() {
//        return success(template.getForObject("http://base/v1/sys_user/user_get/1",ResultReturn.class));
//    }

    public ResultReturn hystrixFail(){
        return failed("系统出现了小问题，请稍后再试");
    }

}
